package com.leo.springbootmultithreadbasic.lock.reentrantlock.basicdemo.demo1;

/**
 * main测试
 *
 * @author Leo
 * @version V1.0
 * @date 2021/10/31 11:41 PM
 */
public class MainDemo {

    public static void main(String[] args) {
        testLock();
    }


    /**
     * Test Scenario: 1 Object and 3 Threads
     *
     * Test Result: 对于同一个对象，当前线程获取锁，当线程执行完毕之后，将锁释放掉，其他线程来争抢该锁。
     */
    public static void testLock() {
        MyService myService = new MyService();

        Thread thread1 = new MyThread(myService);
        Thread thread2 = new MyThread(myService);
        Thread thread3 = new MyThread(myService);

        thread1.start();
        thread2.start();
        thread3.start();

    }

}
